package com.fau.hm.action.index;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.fau.hm.action.PublicAction;
import com.fau.hm.entity.MedicalAdmin;
import com.fau.hm.entity.MedicalCallCheck;
import com.opensymphony.xwork2.ModelDriven;

/**
 * @desc 话务员考核
 * @author dangjh
 * @datetime 2014年12月8日 下午5:59:23
 */
@Controller
@Scope("prototype")
@ParentPackage("default")
@Namespace("/")
public class CallCheckAction extends PublicAction implements ModelDriven<MedicalCallCheck> {

	private static final long serialVersionUID = -1172882583760774027L;
	
	private MedicalCallCheck call = new MedicalCallCheck();
	
	/**
	 * @desc 话务员考核列表页
	 * @return
	 * @author dangjh
	 * @datetime 2014年10月23日,上午9:42:09
	 */
	@Action(value = "init_call_list", results = {@Result(location = "init_call_list.jsp")})
	public String initCallList(){
		return SUCCESS;
	}
	
	/**
	 * @desc 加载话务员考核数据
	 * @return
	 * @author dangjh
	 * @datetime 2014年10月23日,上午9:44:00
	 */
	@Action(value = "call_list_view")
	public String callView(){
		HttpServletResponse response = ServletActionContext.getResponse();
		map = ServletActionContext.getContext().getParameters();
		MedicalAdmin admin = (MedicalAdmin) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		call.setEid(admin.getEnterpriseId());
		pageBean = this.baseAllService.getCheckService().findCallUsers(map, call);
		map.clear();
		map.put("total", pageBean.getTotalRow());
		map.put("data", pageBean.getResult());
		formatJSON(response, map);
		return null;
	}
	
	@Override
	public MedicalCallCheck getModel() {
		return call;
	}

}
